import random
import tracemalloc


def gen_100_num_list():
    ret_list = list()
    for i in range(10000):
        ret_list.append(i)
    return ret_list


def gen_100_str_list():
    char_seed = 'abcdefghijklmnopqrstuvwxyz'
    ret_list = list()
    for i in range(10000):
        str_list = list()
        for j in range(8):
            str_list.append(random.choice(char_seed))
        ret_list.append(''.join(str_list))
    return ret_list


def read_file():
    with open('test_file', 'r', encoding='utf-8') as f:
        f.read()


if __name__ == '__main__':
    tracemalloc.start(10)
    time_start = tracemalloc.take_snapshot()

    gen_100_num_list()
    gen_100_str_list()
    read_file()

    time_end = tracemalloc.take_snapshot()
    stats = time_end.compare_to(time_start, 'traceback')
    for stat in stats:
        print('\n'.join(stat.traceback.format()))
        print('-' * 50)

